package com.gui.controller;

import com.gui.DTO.LimitDTO;
import com.gui.model.User;
import com.gui.service.LimitPageSevice;
import org.h2.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.jws.WebParam;
import javax.servlet.http.HttpServletRequest;

/**
 * PersonalController
 *
 * @author guigu
 * @QQ 1170258867
 * @date 2020/6/4
 * @description
 */
@Controller
@RequestMapping("/personal")
public class PersonalController {

    @Autowired
    private LimitPageSevice limitPageSevice;

    @GetMapping("/mypublish/{page}")
    public String toMyPublish(@PathVariable int page, HttpServletRequest request, Model model){
        model.addAttribute("title","我的问题");
        User user = (User) request.getSession().getAttribute("user");
        LimitDTO limitDTOPerson = limitPageSevice.Bulider(new LimitDTO(),page, user.getId());
        model.addAttribute("limitDTOPerson",limitDTOPerson);
        return "mypublish";
    }

    @GetMapping("/replies/{page}")
    public String toNewReply(@PathVariable int page, HttpServletRequest request, Model model){
        model.addAttribute("title","最新回复");
        System.out.println("最新回复的页码:"+page);
        model.addAttribute("limitDTOPerson",new LimitDTO());
        return "mypublish";
    }

}
